<!DOCTYPE html>
<html>
<title>用户登录</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="./css/w3.css">
<script src="https://cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
<script>

if(!AV.applicationId)
{
AV.init({
  appId: 'hqD9IMTNsFSk2LxbiFnBEvCp-gzGzoHsz',
  appKey: 'ITs4Ni1EiEI5sEcQQ4CBJqpb'
});
}
function ele(id)
{
	return document.getElementById(id);
}

function sendSMS()
{
AV.Cloud.requestSmsCode('18939895003').then(function (success) {
   console.log("sendSMS ok");
  }, function (error) {
  
  console.log("sendSMS error:" + error.message);
  });
}
function verifySMS()
{
  AV.User.signUpOrlogInWithMobilePhone('18939895003', '123456').then(function (success) {
    // 成功
  }, function (error) {
    // 失败
  });
}
function showErrors(message)
{
ele("errormsg").innerHTML = message;
}
function login(e)
{
  e = e||window.event;
  e.innerText = "正在登陆...";
  e.disabled = true;
  var username = ele("name").value;
  var password = ele("password").value;
  AV.User.logIn(username, password).then(function (loginedUser) {
    console.log("login success");
	window.location.href="usermain.html";
  }, function (error) {
    e.innerText = "登陆";
    e.disabled = false;
    showErrors(error.message);
  });
}
</script>
<body>

<div class="w3-content w3-container w3-card-2">
<header class="w3-container w3-teal">
  <h1>用户登录</h1>
</header>

<div class="w3-container w3-half w3-margin-top">
<img class="w3-image" src="./img/man1.jpg">
</div>
<div class="w3-container w3-half w3-margin-top">
<p>
<label>Name:</label>
<input  id="name" class="w3-input" type="text" style="width:90%" required>
</p>
<p>
<label>Password:</label>
<input  id="password" class="w3-input" type="password" style="width:90%" required>
</p>



<p>
<button class="w3-button w3-section w3-teal w3-ripple" onclick="login(this)">登录</button>
<a href="./signup.html">注册</a>
</p>
<p class="w3-text-red" id="errormsg">

</p>

</div>
</div>
</body>
</html> 